package com.licheedev.someext

import android.app.Dialog
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.core.view.get
import androidx.viewbinding.ViewBinding

////////////////////////////// Dialog扩展工具

fun Dialog.rootView(): View {
    return (findViewById<View>(android.R.id.content) as ViewGroup)[0]
}


fun <VB : ViewBinding> Dialog.bind(@LayoutRes layoutRes: Int, bind: (root: View) -> VB): VB {
    setContentView(layoutRes)
    return bind(rootView())
}